package cn.kattomy.shop.index.action;

import java.util.List;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import cn.kattomy.shop.category.service.CategoryService;
import cn.kattomy.shop.category.vo.Category;
import cn.kattomy.shop.categorysecond.service.CategorySecondService;
import cn.kattomy.shop.categorysecond.vo.CategorySecond;
import cn.kattomy.shop.order.service.OrderService;
import cn.kattomy.shop.prevcategory.service.PrevCategoryService;
import cn.kattomy.shop.prevcategory.vo.PrevCategory;
import cn.kattomy.shop.product.service.ProductService;
import cn.kattomy.shop.product.vo.Product;
import cn.kattomy.shop.vo.Page;
/**
 * 访问首页的 Action
 * @author kattomy
 *
 */
public class IndexAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 注入前置分类的 Service
	 */
	private PrevCategoryService prevCategoryService;
	public void setPrevCategoryService(PrevCategoryService prevCategoryService) {
		this.prevCategoryService = prevCategoryService;
	}
	/**
	 * 注入订单的 Service
	 */
	private OrderService orderService;
	public void setOrderService(OrderService orderService) {
		this.orderService = orderService;
	}
	
	/**
	 * 注入一级分类的 Service
	 */
	private CategoryService categoryService;
	/**
	 * 注入二级分类的 Service
	 */
	private CategorySecondService categorySecondService;
	/**
	 * 注入商品的 Service
	 */
	private ProductService productService;
	
	public void setCategorySecondService(CategorySecondService categorySecondService) {
		this.categorySecondService = categorySecondService;
	}

	public void setProductService(ProductService productService) {
		this.productService = productService;
	}

	public void setCategoryService(CategoryService categoryService) {
		this.categoryService = categoryService;
	}

	public String home() {
		System.out.println("Welcome...");
		//查询所有前置分类集合
		List<PrevCategory> prevList = prevCategoryService.findAll();
		//将前置分类存入到Session的范围
		ActionContext.getContext().getSession().put("prevList", prevList);
		return "home";
	}
	
	/**
	 * 电器城
	 * @return
	 */
	public String electrical(){
		return "electrical";
	}
	/**
	 * 超市
	 * @return
	 */
	public String market(){
		return "market";
	}
	/**
	 * 服装城
	 * @return
	 */
	public String clothing(){
		return "clothing";
	}
	/**
	 * 运动场
	 * @return
	 */
	public String sport(){
		return "sport";
	}
	/**
	 * 汽车专区
	 * @return
	 */
	public String car(){
		return "car";
	}
	/**
	 * 图书馆
	 * @return
	 */
	public String book(){
		return "book";
	}

}
